package org.lanqiao.tjut.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.tjut.bean.EmployeeBean;
import org.lanqiao.tjut.model.ModelFactory;

/**
 *学生信息修改跳转： EmployeeInfoModifyDispatchServlet
 */
@WebServlet("/EmployeeInfoModifyDispatchServlet")
public class EmployeeInfoModifyDispatchServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取参数
		//获取跳转路径
		String strJump=request.getParameter("jp")+".jsp";
		
		//获取主键id
		String empId = request.getParameter("sid");
		//获取操作类型参数
		String strOp = request.getParameter("op");
		//根据数据类型进行不同分支流程处理
		if( strOp == null || strOp.equals("")){
			
			EmployeeBean empB =ModelFactory.getEmployeeInfoAddModelInstance().getEmoloyeeInfoById(empId);
			//将查询结果缓存到session中
			request.getSession().setAttribute("empBM", empB);
		}else{
			//调用model层进行删除操作
			ModelFactory.getEmployeeInfoAddModelInstance().deleteEmployeeInfoById(empId);
		}
		request.getRequestDispatcher(strJump).forward(request, response);
		
	}

}
